<template>
  <div class="dashboard-editor-container">
    <panel-group @handleSetLineChartData="handleSetLineChartData" />
    <el-row style="background: #fff; padding: 16px 16px 0; margin-bottom: 32px">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="前端学科" name="first">
          <el-row>
            <el-col :span="16">
              <line-chart :chart-data="lineChartData" />
            </el-col>
            <el-col :span="8">
              <h4 class="ranking">学科试题数量排名</h4>
              <ul>
                <li v-for="(ele, index) in list" :key="index">
                  <span class="index_tit">{{ index + 1 }}</span>
                  <span class="ranking_name">{{ ele.name }}</span>
                  <span class="ranking_num">{{ ele.num }}</span>
                </li>
              </ul>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="JAVA学科" name="second">
          <el-row>
            <el-col :span="16">
              <line-chart :chart-data="lineChartDat1" />
            </el-col>
            <el-col :span="8">
              <h4 class="ranking">学科试题数量排名</h4>
              <ul>
                <li v-for="(ele, index) in list" :key="index">
                  <span class="index_tit">{{ index + 1 }}</span>
                  <span class="ranking_name">{{ ele.name }}</span>
                  <span class="ranking_num">{{ ele.num }}</span>
                </li>
              </ul>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
    </el-row>
  </div>
</template>

<script>
import PanelGroup from './components/PanelGroup'
import LineChart from './components/LineChart'

const lineChartData = {
  newVisitis: {
    actualData: [120, 82, 91, 154, 162, 140, 145, 154, 162, 140, 145, 154, 162]
  }
}
const lineChartDat1 = {
  newVisitis: {
    actualData: [145, 154, 162, 140, 145, 154, 162, 120, 82, 91, 154, 162, 140]
  }
}
export default {
  name: 'DashboardAdmin',
  components: {
    PanelGroup,
    LineChart
  },
  data() {
    return {
      lineChartData: lineChartData.newVisitis,
      lineChartDat1: lineChartDat1.newVisitis,
      activeName: 'first',
      list: [
        { name: '前端', num: 5234 },
        { name: 'java', num: 3210 },
        { name: '大数据', num: 1294 },
        { name: 'C++', num: 1001 },
        { name: 'UI', num: 934 },
        { name: 'PHP', num: 856 },
        { name: 'python', num: 403 },
        { name: '测试', num: 122 }
      ]
    }
  },
  methods: {
    handleSetLineChartData(type) {
      this.lineChartData = lineChartData[type]
    },
    handleClick(tab, event) {
      console.log(tab, event)
    }
  }
}
</script>

<style lang="scss" scoped>
.ranking {
  padding-left: 50px;
}
ul {
  list-style: none;
  font-size: 13px;
  li {
    position: relative;
    height: 35px;
    line-height: 35px;
    .index_tit {
      display: inline-block;
      width: 30px;
      height: 30px;
      line-height: 30px;
      border-radius: 50%;
      background-color: #f4f4f4;
      text-align: center;
    }
    .ranking_name {
      margin-left: 30px;
    }
    .ranking_num {
      margin-right: 20px;
      position: absolute;
      right: 0;
    }
  }
  li:nth-child(1),
  li:nth-child(2),
  li:nth-child(3) {
    .index_tit {
      display: inline-block;
      font-weight: 700;
      color: #fff;
      width: 30px;
      height: 30px;
      line-height: 30px;
      border-radius: 50%;
      background-color: #2f3556;
      text-align: center;
    }
  }
}
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
